<!DOCTYPE html>
<html lang="zh_CN" xmlns:th="http://www.thymeleaf.org">

<head>
  <base th:href="@{/}">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title th:text="${systemName}"></title>
  <link rel="stylesheet" href="static/layui/css/layui.css" media="all" />
  <link rel="stylesheet" href="static/plugin/font-awesome/css/font-awesome.min.css" media="all" />
  <link rel="stylesheet" href="static/plugin/build/css/app.css" media="all" />
  <link rel="stylesheet" href="static/plugin/build/css/themes/default.css" media="all" id="skin" kit-skin />
  <style>
    .layui-footer {
      background-color: #2F4056;
    }
    .layui-side-scroll {
      border-right: 3px solid #009688;
    }
    .kit-nav .layui-nav-item .layui-nav-more {
      top: 0px;
    }
  </style>
</head>

<body class="kit-theme">
<div class="layui-layout layui-layout-admin kit-layout-admin">
  <div class="layui-header">
    <div class="layui-logo"><span th:text="${systemName}" /></div>
    <div class="layui-logo kit-logo-mobile"></div>
    <div class="layui-hide-xs">
      <!-- <ul class="layui-nav layui-layout-left kit-nav">
          <li class="layui-nav-item"><a href="javascript:s();">会员管理</a></li>
          <li class="layui-nav-item"><a href="javascript:;" kit-target
              data-options="{url:'/article/articleList',icon:'&#xe658;',title:'文章管理',id:'966'}">文章管理</a></li>
          <li class="layui-nav-item"><a href="javascript:;">其它系统</a>
              <dl class="layui-nav-child">
                  <dd>
                      <a href="javascript:;">邮件管理</a>
                  </dd>
                  <dd>
                      <a href="javascript:;">消息管理</a>
                  </dd>
                  <dd>
                      <a href="javascript:;">授权管理</a>
                  </dd>
              </dl></li>
      </ul> -->
    </div>
    <ul class="layui-nav layui-layout-right kit-nav">
      <li class="layui-nav-item"><a href="javascript:;"> <i
              class="layui-icon">&#xe63f;</i> 皮肤
      </a> </a>
        <dl class="layui-nav-child skin">
          <dd>
            <a href="javascript:;" data-skin="default" style="color: #00c0ef;"><i class="layui-icon">&#xe658;</i>
              默认</a>
          </dd>
          <dd>
            <a href="javascript:;" data-skin="orange" style="color: #ff6700;"><i class="layui-icon">&#xe658;</i> 橘子橙</a>
          </dd>
          <dd>
            <a href="javascript:;" data-skin="green" style="color: #00a65a;"><i class="layui-icon">&#xe658;</i> 春天绿</a>
          </dd>
          <dd>
            <a href="javascript:;" data-skin="pink" style="color: #FA6086;"><i class="layui-icon">&#xe658;</i> 少女粉</a>
          </dd>
          <dd>
            <a href="javascript:;" data-skin="red" style="color: #dd4b39;"><i class="layui-icon">&#xe658;</i> 枫叶红</a>
          </dd>
        </dl></li>
      <li class="layui-nav-item"><a href="javascript:;"><!--  <img
						src="/images/2d4c37c3-c106-4288-9c0d-e7fe1b8adc72.jpeg"
						class="layui-nav-img"> --><span th:text="${user.userName}">admin</span>
      </a>
        <dl class="layui-nav-child">
          <dd>
            <a href="javascript:;" kit-target data-options="{url:'user/basic',icon:'&#xe658;',title:'基本资料',id:'966'}"><span>基本资料</span></a>
          </dd>
          <dd>
            <a href="javascript:;" kit-target
               data-options="{url:'user/updatePwdHtml',icon:'&#xe658;',title:'修改密码',id:'967'}"><span>修改密码</span></a>
          </dd>
        </dl></li>
      <li class="layui-nav-item"><a href="loginOut"><i
              class="fa fa-sign-out" aria-hidden="true"></i> 注销</a></li>
    </ul>
  </div>

  <div class="layui-side layui-nav-tree layui-bg-black kit-side">
    <div class="layui-side-scroll">
      <div class="kit-side-fold">
        <i class="fa fa-navicon" aria-hidden="true"></i>
      </div>
      <ul class="layui-nav layui-nav-tree" lay-filter="kitNavbar"
          kit-navbar>
        <li class="layui-nav-item" th:each="e:${list}" >
          <a th:if="${e.menuUrl eq null || e.menuUrl eq ''}" class="" href="javascript:;" th:onclick="superClick([[${e.id}]])">
            <i aria-hidden="true" class="layui-icon" th:text="${e.menuIcon}"></i>
            <span th:text="${e.menuName}"></span>
          </a>
          <dl th:if="${e.menuUrl eq null || e.menuUrl eq ''}" th:id="${e.id}" class="layui-nav-child"></dl>
          <a th:if="${e.menuUrl ne null && e.menuUrl ne ''}" href="javascript:;" kit-target
             th:data-options="'{url:\''+${e.menuUrl}+'\',icon:\''+${e.menuIcon}+'\',title:\''+${e.menuName}+'\',id:\''+${e.id}+'\'}'">
            <i class="layui-icon">&#xe6af;</i><span th:text="${e.menuName}"></span>
          </a>
        </li>
      </ul>
    </div>
  </div>

  <div class="layui-body" id="container">
    <!-- 内容主体区域 -->
    <div style="padding: 15px;">
      <i class="layui-icon layui-anim layui-anim-rotate layui-anim-loop">&#xe63e;</i>
      请稍等...
    </div>
  </div>

  <div class="layui-footer" style="text-align: center;">
    <!-- 底部固定区域 -->
    重庆新目标科技
  </div>
</div>
<script src="static/layui/layui.js"></script>
<script src="static/plugin/tools/main.js"></script>
<script type="text/javascript">
  var $,element;
  layui.use(['element'],function(){
    $ = layui.jquery,
            element = layui.element;
  })

  var bindMenuEvent = function($con){
    $con = $($con);
    $con.find("a[lay-filter]").on("click",function(){
// 				var $this = $(this);
// 				var dataStr = $this.attr("data-options");
// 				var dataJson = {};
// 				try{
// 					dataJson = JSON.parse(dataStr);
// 				}catch(e){}
// 				console.log(dataJson);
// 				element.tabAdd($this.attr("lay-filter"),{
// 		             	title:dataJson.title
// 	                    ,content: '<iframe src="'+dataJson.url+'" style="width:100%;height:491px;" scrolling="auto" frameborder="0"></iframe>'
// 	                    ,id: dataJson.id
// 				});
      var _that = $(this);
      var options = _that.data('options');
      var data;
      if (options !== undefined) {
        try {
          data = new Function('return ' + options)();
        } catch (e) {
          layui.hint().error('Navbar 组件a[data-options]配置项存在语法错误：' + options)
        }
      } else {
        data = {
          icon: _that.data('icon'),
          id: _that.data('id'),
          title: _that.data('title'),
          url: _that.data('url'),
        };
      }
      layui.tab.tabAdd(data);
    })

  }
  function superClick(id){
    $.post('/menu/openMenu',{"id":id},function(d){
      if(d.length == 0){
        return;
      }
      var html = '';
      $.each(d,function(index,e){
        if(e.menuUrl == null || e.menuUrl == ""){
          html+='<dd><a class="" href="javascript:;" onclick="superClick(\''+e.id+'\')">'+
                  '<i aria-hidden="true" class="layui-icon">'+e.menuIcon+'</i>'+
                  '<span>'+e.menuName+'</span>'+
                  '</a>'+'<dl id="'+e.id+'" class="layui-nav-child"></dl>'+'</dd>';
        }else{
          html+='<dd><a href="javascript:;" kit-target lay-filter="lazyloadmenu"'+
                  'data-options="{\'url\':\''+e.menuUrl+'\',\'icon\':\''+e.menuIcon+'\',\'title\':\''+e.menuName+'\',\'id\':\''+e.id+'\'}">'+
                  '<i class="layui-icon">'+e.menuIcon+'</i><span>'+e.menuName+'</span></a></dd>';
        }
      });
      $("#"+d[0].supperId).html(html);
      //重新渲染
      element.init();
      bindMenuEvent($("#"+d[0].supperId));
    },'json');
  }
</script>
</body>

</html>
